package com.henry.oddeven;

import java.util.Objects;

public class Even extends Natural {

    public Even(int valIn) throws OddEvenException {
        super(valIn);
        if (valIn % 2 != 0) throw new OddEvenException(valIn + " is not an even number.");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        return val == ((Even) o).val;
    }

    @Override
    public int hashCode() {
        return Objects.hash(val);
    }

    @Override
    public String toString() {
        return "Even{" + "val=" + val + '}';
    }
}
